import { createApp, reactive } from 'vue'
import loading from '@/components/pro-loading/index.vue'
const msg = reactive({
  show: false,
  title: '正在加载中...'
})
const $loading = createApp(loading, { msg }).mount(
  document.createElement('div')
)

const load = {
  show(title?: string) {
    msg.show = true
    if (title) {
      msg.title = title
    }
    const appendEl = document.querySelector('.n-config-provider')
    appendEl && appendEl.appendChild($loading.$el)
  },

  hide() {
    msg.show = false
  }
}
export { load }
